package com.wechat.scheme.controller.admin;

import com.wechat.scheme.entity.BaiduSource;
import com.wechat.scheme.entity.SchemeUser;
import com.wechat.scheme.entity.model.LoginModel;
import com.wechat.scheme.entity.model.SchemeUserVo;
import com.wechat.scheme.entity.model.SourceSearchMo;
import com.wechat.scheme.repo.BaiduSourceRepo;
import com.wechat.scheme.repo.SchemeUserRepo;
import com.wechat.scheme.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/admin/source")
public class SourceCtrl {

    @Autowired
    BaiduSourceRepo baiduSourceRepo;

    @PostMapping("/list")
    public Response list(@RequestBody SourceSearchMo mo){
       List<BaiduSource> sourceList = baiduSourceRepo.findByKeyWordLike(mo.getKeyWord());
        return Response.succeed(sourceList);
    }

    @GetMapping("/del/{id}")
    public Response del(@PathVariable String id){
        baiduSourceRepo.softDeleteById(id);
        return Response.succeed();
    }

    @PostMapping("/put")
    public Response put(@RequestBody BaiduSource source){
        baiduSourceRepo.save(source);
        return Response.succeed();
    }



}
